MV_CC_SetSDKLogPath

MV_CC_SetSDKLogPath

Set the SDK log saving path.

API Definition

int MV_CC_SetSDKLogPath(
 const char      *pSDKLogPath
);

Parameters

pSDKLogPath

[IN] SDK log saving path.

Return Value

Return MV_OK(0) on success, and return Error Code on failure.

Remarks

For version 2.4.1 and above, the log service has added, and no need to set the log saving path, therefore this API is invalid when the log service is enabled.

The following sample code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;
    //Enumerate all devices of specific transport protocol in the subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }
    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }
    string strPath = "D:/SDK";
    nRet = MV_CC_SetSDKLogPath(strPath.c_str());
    if (MV_OK != nRet)
    {
        printf("error: Set SDK Log Path fail [%x]\n", nRet);
        return;
    }
    //Select the first found online device and create handle
    int nDeviceIndex = 0;
    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));
    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);
    if (MV_OK != nRet)
    {
         printf("error: CreateHandle fail [%x]\n", nRet);
         return;
    }
    //Connect to device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;
    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
         printf("error: OpenDevice fail [%x]\n", nRet);
         return;
    }
    //Other process...

    //Close camera
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
          printf("error: CloseDevice fail [%x]\n", nRet);
          return;
    }
    //Destroy handle and release resources
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
          printf("error: DestroyHandle fail [%x]\n", nRet);
          return;
    }
}

MV_CC_SetSDKLogPath

Set the SDK log saving path.

API Definition

int MV_CC_SetSDKLogPath(
 const char      *pSDKLogPath
);

Parameters

pSDKLogPath

[IN] SDK log saving path.

Return Value

Return MV_OK(0) on success, and return Error Code on failure.

Remarks

For version 2.4.1 and above, the log service has added, and no need to set the log saving path, therefore this API is invalid when the log service is enabled.

The following sample code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;
    //Enumerate all devices of specific transport protocol in the subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }
    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }
    string strPath = "D:/SDK";
    nRet = MV_CC_SetSDKLogPath(strPath.c_str());
    if (MV_OK != nRet)
    {
        printf("error: Set SDK Log Path fail [%x]\n", nRet);
        return;
    }
    //Select the first found online device and create handle
    int nDeviceIndex = 0;
    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));
    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);
    if (MV_OK != nRet)
    {
         printf("error: CreateHandle fail [%x]\n", nRet);
         return;
    }
    //Connect to device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;
    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
         printf("error: OpenDevice fail [%x]\n", nRet);
         return;
    }
    //Other process...

    //Close camera
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
          printf("error: CloseDevice fail [%x]\n", nRet);
          return;
    }
    //Destroy handle and release resources
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
          printf("error: DestroyHandle fail [%x]\n", nRet);
          return;
    }
}